Declare @lDateFrom As DateTime = N'2014-11-10'
Declare @lDateTo As DateTime = N'2014-11-12'
----------------------------------------

;with [data] As
(
Select
       [identification]
      ,[step_number]
      ,[recipe_name]
      ,[recipe_cement]
      ,[recipe_struska]
      ,[recipe_kamenivo1]
      ,[recipe_kamenivo2]
      ,[recipe_kamenivo3]
      ,[recipe_kamenivo4]
      ,[recipe_kamenivo5]
      ,[recipe_prisady]
      ,[recipe_rezerva]
      ,[rezerva1]
      ,[rezerva2]
      ,[prumer_vlhkost3]
      ,[prumer_vlhkost4]
      ,[navyseni3]
      ,[navyseni4]
      ,[rezim_k3]
      ,[rezim_k4]
      ,[rezerva3]
      ,[rezerva4]
      ,[rezerva5]
      ,[rezerva6]
      ,[cement_silo1]
      ,[cement_silo2]
      ,[struska_silo3]
      ,[cement_silo4]
      ,[cement_silo5]
      ,[kamenivo_silo1]
      ,[kamenivo_silo2]
      ,[kamenivo_silo3]
      ,[kamenivo_silo4]
      ,[kamenivo_silo5]
      ,[prisady]
      ,[cement_struska_zbytek]
      ,[kamenivo_zbytek]
      ,[rezerva7]
      ,[rezerva8]
      ,[rezerva9]
      ,[rezerva10]
      ,Min([x_created]) As [x_created]
From
	[dbo].[receive_data]
Where
	[x_created] Between @lDateFrom And @lDateTo
Group By
       [identification]
      ,[step_number]
      ,[recipe_name]
      ,[recipe_cement]
      ,[recipe_struska]
      ,[recipe_kamenivo1]
      ,[recipe_kamenivo2]
      ,[recipe_kamenivo3]
      ,[recipe_kamenivo4]
      ,[recipe_kamenivo5]
      ,[recipe_prisady]
      ,[recipe_rezerva]
      ,[rezerva1]
      ,[rezerva2]
      ,[prumer_vlhkost3]
      ,[prumer_vlhkost4]
      ,[navyseni3]
      ,[navyseni4]
      ,[rezim_k3]
      ,[rezim_k4]
      ,[rezerva3]
      ,[rezerva4]
      ,[rezerva5]
      ,[rezerva6]
      ,[cement_silo1]
      ,[cement_silo2]
      ,[struska_silo3]
      ,[cement_silo4]
      ,[cement_silo5]
      ,[kamenivo_silo1]
      ,[kamenivo_silo2]
      ,[kamenivo_silo3]
      ,[kamenivo_silo4]
      ,[kamenivo_silo5]
      ,[prisady]
      ,[cement_struska_zbytek]
      ,[kamenivo_zbytek]
      ,[rezerva7]
      ,[rezerva8]
      ,[rezerva9]
      ,[rezerva10]
)

Select
	*,
	DATEADD(ms, DATEDIFF(ms, GETUTCDATE(), GETDATE()), [data].[x_created]) As [local_date],

	cast(floor(cast(cast([data].[x_created] as datetime) as float(53)) * 4) / 4 as datetime) As [shift]
From
	[data]